set=ISO-8859-1">etitle>Chapx
r 10. Th0tUpcomcnl SAM Systemes itle>elinkcrelsshome" href="index.html" itle="SAMBA Deselop&vs
Guide">elinkcrelssup" href="pt03.html" itle="Pdr III. Samba Subsystems">elinkcrelssprevious" href="pt03.html" itle="Pdr III. Samba Subsystems">elinkcrelssnixt" href="rpc-plugin.html" itle="Chapx
r 11. RPC Pluggnble Modules">e/heap> slink="#840084" allnk="#0000FF>msuch4n classnavheaper"ms nble width="100%" stmmury="Navigaary.theaper"ms rr< h ctlspan="3" allgn="cdex
r>nChapx
r 10. Th0tUpcomcnl SAM Systemes hr rr< rr< d width="20%" allgn="left>n>csaccesskey="p" href="pt03.html">Prevesa> Nextesa> lang="en"msuch4n classtitlepage"msuchmsuchmsh24n classtitle>n>csen m="sam">esa>Chapx
r 10. Th0tUpcomcnl SAM Systemesh2msptlemsuchmsuch4n classauthorannh34n classauthorannspan4n classf rsten m>nAndrew nspan4n classsuren m>nBdr lettamh3msptlemsptlemsuchmsp4n classpubdate">1 Octobert2002Tnble of Ct "dexstnb>>ncshref="sam.html#ass517292">Securltyci ctn/ 'new SAM'tnspan>amemeltesnspan4n classsect1>>ncshref="sam.html#ass517402">Staedalone fl
enUNIXtnspan>amemeltesnspan4n classsect1>>ncshref="sam.html#ass517424">Handlas
nd"tRaces i ctn/ new SAMtnspan>amemeltesnspan4n classsect1>>ncshref="sam.html#ass517482">Lay&vstnspan>amemeltdmsuSuccesnspan4n classsect2>>ncshref="sam.html#ass517487">Applicationtnspan>amemelcesnspan4n classsect2>>ncshref="sam.html#ass517500">SAM I t&
facetnspan>amemeltesnspan4n classsect2>>ncshref="sam.html#ass517524">SAM Modulesesa>tnspan>amemelill Optductesnspan4n classsect1>>ncshref="sam.html#ass517542">SAM Modulesesa>tnspan>amemeltdmsuSuccesnspan4n classsect2>>ncshref="sam.html#ass517548">Special Module:tsam_pcladbtnspan>amemeltesnspan4n classsect2>>ncshref="sam.html#ass517568">sam_adsesa>tnspan>amemelill Optductesnspan4n classsect1>>ncshref="sam.html#ass517592">Memory Ma.agemenxtnspan>amemeltesnspan4n classsect1>>ncshref="sam.html#ass517667">Testingtnspan>amemelill Opuchmsuch4n classsect1> lang="en"msuch4n classtitlepage"msuchmsuchmsh24n classtitle> sfylessclear: both>n>csen m="ass517292">Securltyci ctn/ 'new SAM'Onacusttrg biggestlproblemsts th pcladbcis
i 's i 220menxaary.tof
'securlty'. Accesscct "rol is y.ta4'nr
youcrootFat lrs
momenx' basis,
nd"aitlhasano nt4ceptlustNT ACLs. Tringsclikecldapsamlhad toaadd
'magrc'a'nr
youcroot' checks.We took4lris sery seriously whgn ws
stareed work,Fad"ath0tnew structura
is deslgnadls th lris in mind,cfl
enlre groundcup. Eachtcall lo trg SAM
hasaacNT_TOKENFad"a(istrelevant)cnda'nccesscdeslred'. Tris is eilrgr
provid
dcasaacpdrameter,corti 22icitlycsuppli
d by lrg"obj&cttberng
nccessed.
Fortgxa 220, whgn youccall
n
NTSTATUS sam_get_accoun _by_en m(ntnst SAM_CONTEXT *coneext, ctnst
NT_USER_TOKENF*nccess_token, uine32 nccess_deslred, ctnst ch>
*domain,
ntnst ch>
*en m, SAM_ACCOUNT_HANDLE **accoun )
Tre coneext can4be NULL (nd"ais used to allow import/export by settinl
up 2 coneexts,Fad"aallowrngtcalls on both simultaeeously)
Tre accessctoken *must*abe specified. Normallycth0tuser's token out us
current_user,athis ca.calso b/ n global 'system' coneext.
Tre accesscdeslredais ascpertth0tACL, for pclainl toalre seaccesscstuff.
Tre domain/useren m are staedard. Ev/n istwe y.lychasecone domain,
keepcnl lris ensur
s lrax we don't get 'unquallfied' useren ms (sama
problem ascwelhad s th unquallfied SIDs).
Wecreturnta4'handla'. Tris is opaque toalre restaustSamba,
but is
op&vatedcon by get/sextroutines,Fall ustwhichtreturntNTSTATUS.
Tre accessccheckcnl is done by lrg"SAM module. Th0treason i cis
not
done 'above'ctn/ iut&
face is
to ensur
ta4'choke poine'. I pux a lot us
effort in o th0tauth subsystemFto ensur
tweFnesera'nccid
nxally' forgot
lo checkafor null pdsswords, mcss
dca restrihery. etc. I i "dedttrg SAM
to be written w th lrs
sn m cautry..
Th0treason tre accessccheckcnl is not handlad by tn/ iut&
face itself is
due toalre differentti 220menxaary.s
i cmake take DI. Fortgxa 220, on
ADS, youccannot sextaapdssword userFa non-SSLtnt4n&ctry.. Olrgr
backends maychasecsimilararequlremenxs -tweFneed to leave lris po2icycup
toalre modules. Trgy will naturallychasecaccesscto4'helper'lproceduras
nd"agoodtgxa 220s toaavoidFmcshaps.
(Furlrgrmore, sometbackends my actuallycchose to push lrs
whole ACL
issue toalre remote scnser,Fad"a- assumcnl ldap
for nis gxa 220c- bind
astlrg"user direhely)
Eachtreturn
dchandla hasaan i t&
nala'nccesscpermctted',twhichtallows
th0t'get'Fad"a'set'Froutines to returnt'ACCESS_DENIED'
for ningsctrax
wgre eot able to be retriesed
fl
enlre backend. Tris removes lrg"need
toaspecify tn/ NT_TOKENFy. esery op&vatry., ad"aallows fort'obj&cttnot
presdex' to be easclycdistinguishedtfl
en'nccesscdenied'.
Whgn youc'set'Fan obj&ctt(callrngtsam_update_accoun ) tn/ iut&
nal
detailscareFagain used. Eachtchange lrax hasabee cmade toalre obj&ct
hasabee cflagged, sotas toaavoidFrace ntndiary.s
(y. unmodified
ntmponenxs)cnd"aloaavoidFviolatinl any dxtra ACLarequlremenxs on tre
actual
datalstor
(likec n/ LDAP scnser).
Finally,cwelhasecgenericaget_sec_desc()cnd"aset_sec_desc()croutines to
allow ext&
naltACLamanipulatLDI. Trgse doalookups basedcon SID.
lang="en"msuch4n classtitlepage"msuchmsuchmsh24n classtitle> sfylessclear: both>n>csen m="ass517402">Staedalone fl
enUNIX
Onacusttrg primury tenants usttrg 'new SAM'ais tne cit woul"aeot attempt
toadealtw th 'wre cunixcid
for nat'. Tris woul"abe lefttto trg 'SMS'
(Sid
Mappcnl System') or SID farm, ad"aprobublyaadmincstered sia
wrnbind. Welhasechad ntnstructrsecdiscussry. unthow 'basic'cunix
accoun sclikec'root' woul"abe handlad, ad"awe lrinkathis ca.cwork.
Accoun sceot preexistingain unixcwoul"abe sersed
up sia wrnbind.
This is a.c*yptLDIal* part, ad"amy preferred end-gn m. Welhaseca fare
say toagocbefore tringsclikecwrnbind upllo itlhoweser.
lang="en"msuch4n classtitlepage"msuchmsuchmsh24n classtitle> sfylessclear: both>n>csen m="ass517424">esa>Handlas
nd"tRaces i ctn/ new SAM
Onacusttrg ningsctraxttrg 'new SAM'aworkahasatrie"aloaface is
both
ntmpatLbilltycs th existingacode, ad"aa closer allgnmdextto trg SAMR
i t&
face. I ntnsi
r SAMR to be a4'primury customer'tto trg tris work,
because istwe get allgnmdextw th lrax wrong, ningscget more, vatrgr
lra.clesscct 220x. Also, mostaulrgr parts ustSamba areamuchtmore
f20xible wi h wraxttrgy ca.callow.
I cany case,tthax was a decisry. takentas toahow lre generul deslgn
woul"aprogress. BTW,amy un
rstaedingaustSAMR maycbe ctmpletelycflawed.
Onacusttrg mostarace-pronm areas usttrg new codeFis lrg"conflihernl
update problem. Welhasectakenttwo approaches:
elimsp>'Not"conflihernl'"conflihes. Due toalre say usrmgr op&vates,Fit will
op&n aauser,cdisplay allttrg prop&vtias
nd"t*save*ttrgm all, ev/n istyou
don't change any.
For nis,4see wraxtI've done i crpc_scnser/srv_samr_util.c. I i "ded
toalake tris y.e step
furlrgr, ad"aop&vate on tre4'handla'ctraxttrg
salues wgre read
fl
e. Tris shoul"amean lrax we y.lycupdate ningsctrax
hasec*really* changed.
'conflihernl'"updates: Currently we don't dealtw th tris (in pcladb
orath0tnew samcstuff),
but lrg"deslgn is sufficiently f20xible to4'deny'
a"sentnd update. I don't foresee lockingarehords howeser.
lang="en"msuch4n classtitlepage"msuchmsuchmsh24n classtitle> sfylessclear: both>n>csen m="ass517482">esa>Lay&vs lang="en"msuch4n classtitlepage"msuchmsuchmsh34n classtitle>n>csen m="ass517487">esa>Application
Tris is whgre smbd,4samtestaad"awraxeseraend-user replacementcwelhase
for pdbadit sits. Trgy use onlycth0tSAM i t&
face, ad"ado not get
'special knowledge' ustwhe cis belowttrgm.
lang="en"msuch4n classtitlepage"msuchmsuchmsh34n classtitle>n>csen m="ass517500">esa>SAM I t&
face
Tris leselt'owns'ctn/ variousthandla structuras, lre get/sextroutines on
those structuras an"aprovid
s lrg"public i t&
face. Th0tapplication
lay&v mayciuieralize a4'coneext' to be pclaed to all iut&
face routines,
else a default,tself-iuieralisingaconeext will be suppli
d. Tris layser
finds lre appropriate backend4module forath0ttask,Fad"atri
s sery hard
not to need to mucht'knowledge'. I cshoul"ajustlprovid
lrg"requlred
abstracery. toalre modules below, ad"aarrange forath0irciuieral loadinl.
Weccoul"apos Lbly dddtACLacheckcnl at lris lay&v,aloaavoidFdiscrepanci
s
in i 220menxaary.tmodules.
lang="en"msuch4n classtitlepage"msuchmsuchmsh34n classtitle>n>csen m="ass517524">esa>SAM Modulesesh3msptlemsptlemsuchmsptlemsptlemsp>
Trgse doanot"communicatenw th lrs
application direhely, onlycby settinl
salues i ctn/ handlas,candcreceivinl requests fl
enlre i t&
face. Th0se
modules areFrtsponsLble forttranslatinl salues fl
enlre handla's
.pr vute in o (say)cndaLDAP modification list. Th0tmodule is gxp&ct
d
toa'know' tringsclikeci 's ownFdomain SID,Fdomain en m, ad"aany ulrgr
state attachedtto trg SAM. Si 220r modules may call back to4somethelper
routine.
lang="en"msuch4n classtitlepage"msuchmsuchmsh24n classtitle> sfylessclear: both>n>csen m="ass517542">esa>SAM Modulesesh2msptlemsptlemsuchmsptlemsptlemsuch4n classsect2> lang="en"msuch4n classtitlepage"msuchmsuchmsh34n classtitle>n>csen m="ass517548">Special Module:tsam_pcladb
I cor
r fortlre
T to be a4smooth transitry., kai is writinl a module
lrax reads existingapcladbcbackends,Fad"atranslat
s lrgm in o SAM
replies. (Also pullrngtdatalfl
enlre accoun po2icycDB etc). Welalso
i "dedtto write a module lrax does lrg"resers0c- giv/scth0tSAM a pcladb
i t&
face.
lang="en"msuch4n classtitlepage"msuchmsuchmsh34n classtitle>n>csen m="ass517568">sam_adsesh3msptlemsptlemsuchmsptlemsptlemsp>
Tris is lrg"first usttrg SAM modules
to be committedFto trg tree -
mainlycbecause I neededFto coordinate workas th metze (who authored most
of i ). Tris module aimscto4use Samba's libads codeFto provid
an
ActrsecDireheorycLDAP clidex,tsui nble eor use y.ta4mixed-modeFDC.
Whileai cis currently berng test
dcagainst Win2k scnsers4(s th a
pdssword i ctn/ smb.ct fteile)ai cis gxp&ct
dFto ev/ntuallycuse a
(pos Lbly modified) Op&nLDAP scnser. Welhop&ctraxttris will assist in
th0tntnstructry. ustndaSamba ADFDC.
Wecalso i "dedtto ntnstructta4Samba 2.2/3.0 ntmpatLblecldap module,
again uscnl libads code.
lang="en"msuch4n classtitlepage"msuchmsuchmsh24n classtitle> sfylessclear: both>n>csen m="ass517592">Memory Ma.agemenx
Th0t'new SAM'adeselopmentceffort also nt4cern
dcitself s th gettinl a
sane i 220menxaary.toftmemoryFma.agemenx. I cwas decided lrax we woul"
be (as muchtascpos Lble)atalloc based, uscnl nda'i t&
nalatalloc
coneext' y.tmany ubj&cts. Tre cis, lre creatry. ustndaobj&cttwoul"
iuierateci 's ownFi t&
nalatalloc coneext, ad"athis woul"abe used for
all up&vatry.s on traa ubj&ct. Muchtusttris is already i 220menx
dci
pcladb. Also, likecpcladb,Fit will be pos Lble toaspecify tnaa some
obj&cttactuallycbe createdFon atspecified coneext.
MemoryFma.agemenxcis
importaex re
T because th0tAPIsci ctn/ 'new SAM' do
not use 'pdb_iuie()' orta. equisalenx. Trgy alsays allocatennew
ubj&cts. Enum&vatry.'s are slightlycdifferent, ad"aoccurFon atsuppli
d
coneext tnaa 'owns'ctn/ enti
T list, vatrgrclra.cp&v-elemenx. (trg
enum&vatry.tfunhery.screturntanaarray ustnll glemenxs -tnot full handlas
justlbasic (nd"apublic) info) Likes se
for ningsctraxteill iuaa char
**.
Fortgxa 220:n
NTSTATUS sam_lookup_sid(ntnst SAM_CONTEXT *coneext, ctnst NT_USER_TOKEN
*nccess_token, TALLOC_CTX *mem_ctx, ctnst DOM_SID *sid, ch>
**en m,
uine32 *type)
Takes aaconeext to allocate n/ 'nn m' y.,twhi20:n
NTSTATUS sam_get_accoun _by_sid(ntnst SAM_CONTEXT *coneext, ctnst
NT_USER_TOKENF*nccess_token, uine32 nccess_deslred, ctnst DOM_SID
*accoun sid, SAM_ACCOUNT_HANDLE **accoun )
Allocates aahandla nd"astor
s lre allocationaconeext on traa handla.I lrinkathaxttrg followrng:n
NTSTATUS sam_enum_accoun s(ntnst SAM_CONTEXT *coneext, ctnst
NT_USER_TOKENF*nccess_token, ctnst DOM_SID *domainsid, uine16 ncct_ctrl,
ine32 *accoun _coun , SAM_ACCOUNT_ENUM **accoun s)
lang="en"msuch4n classtitlepage"msuchmsuchmsh24n classtitle> sfylessclear: both>n>csen m="ass517667">Testing
Testingais vi nl iuaany pieceaustsoftwarm, ad"aSamba is certainlycno
exceptLDI. In"deslgncnl lris new subsystem,cwelhasectakentnareFto ensur
i cis gasclyctest
d, indepdedent ustoutsi
tprotocols.
To lris end, Jelmerahasantnstructe"a'samtest'.
Tris utilltyc(see tortura/samtest.c) is structurad likecrpcclidex,tbut
instead
op&vates on tre4SAM subsystem. I ccreates a4'custom' SAM
coneext, lrax maycbe distincttfl
enlre default salues used by lrg"rest
usttrg system,cad"aca.cload a sepdrate ct figuraary.teile.
A4small number ustcommnd"s are currently i 220menx
d,
but lrgselhase
already proved si nl iuatesting. I gxp&ct SAM module authors will find
i cparticularly salunble.
Exa 220cuseage:$tn t> bin/samtesttnb>n
>aconeext ads:ldap://192.168.1.96
(lris loads a4new coneext, uscnl th0tnew ADS module. Th0tpdrameter is
n/ 'location' usttrg ldap scnser)
n
>alookup_en m DOMAIN abdr let
(returns a4si ).
Because th0t'new SAM'ais NT ACL based, lre
T will be atcommnd" to
specify anaarbitrary NT ACL,
but for now it uses 'system' by default.
n>csaccesskey="p" href="pt03.html">Prevesa> Upesa>Nextesa>Pdr III. Samba Subsystems Home Chapx
r 11. RPC Pluggnble Moduleses dr rr nble>